package com.android.route;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MyItemOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> listOverlayItem = new ArrayList<OverlayItem>();

	// constructor tạo 1 marker và địa điểm sẽ nằm ở giữa và dưới của marker
	public MyItemOverlay(Drawable defaultMarker) {

		super(boundCenterBottom(defaultMarker));
		// TODO Auto-generated constructor stub
	}

	public void addItem(GeoPoint geoPoint, String title, String snippet) {
		OverlayItem newItem = new OverlayItem(geoPoint, title, snippet);
		// them toa do vao list
		// Each time you add a new OverlayItem to the ArrayList, you must call
		// populate()
		// for the ItemizedOverlay,
		// which will read each of the OverlayItems and prepare them to be
		// drawn.
		listOverlayItem.add(newItem);
		populate();
	}

	// methods are generated by itself
	@Override
	protected OverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return listOverlayItem.get(i);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return listOverlayItem.size();
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		// TODO Auto-generated method stub
		super.draw(canvas, mapView, shadow);
	}

}
